﻿<%@ WebHandler Language="C#" Class="wxMiniProgramLogin" %>
using Models;
using System;
using System.Web;
using Newtonsoft.Json;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Net;
using Newtonsoft.Json.Linq;
using System.Collections;

public class wxMiniProgramLogin : IHttpHandler {
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";

        StreamReader sr = new StreamReader(HttpContext.Current.Request.InputStream);
        string responseStr = sr.ReadToEnd();
        if (string.IsNullOrEmpty(responseStr.ToString()))
        {
            HttpContext.Current.Response.Write("parameter error");
            return;
        }
        JObject jo = (JObject)JsonConvert.DeserializeObject(responseStr);
       int theid = int.Parse(jo["id"].ToString());


        string authHeader = context.Request.Headers["token"];//Header中的token
        if (string.IsNullOrEmpty(authHeader))
        {
            HttpContext.Current.Response.Write("parameter error");
            return;
        }

        using (Entities bll = new Entities())
        {

                var mnews = bll.S_Order.Where(p => p.OParentId ==theid || p.OrderID == theid);//全部

   
                foreach (var xx in mnews)
                {
               
                xx.OState = -1;
                bll.SaveChanges();

                }


            var code = 1;
            var msg = "取消成功";
            var time = DateTime.Now;



            context.Response.Write(JsonConvert.SerializeObject(new { code,msg,time}));

        }

        HttpContext.Current.Response.End();

    }



    public bool IsReusable {
        get {
            return false;
        }
    }

}